import socket
import struct
def main():
    tcp_server=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    tcp_server.bind(('127.0.0.1',8000))
    tcp_server.listen()
    conn,addr=tcp_server.accept()#阻塞
    mas=input('请输入要发送的数据').encode('utf-8')
    msg2=input('请输入要发送的数据').encode('utf-8')
    mas_lenth=struct.pack('i',len(mas))
    conn.send(mas_lenth)
    conn.send(mas)
    conn.send(msg2)
    conn.close()
    tcp_server.close()
if __name__ == '__main__':
    main()